package nocuffin.m5;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class UserMasterTest {

	@Test
	public void testValidateUser() {
		UserMaster tester = new UserMaster();
		//Simple, easy, valid dates
		assertEquals("Result", true, tester.validateDate("09/08/2012"));
		assertEquals("Result", true, tester.validateDate("12/25/1997"));
		assertEquals("Result", true, tester.validateDate("03/15/2001"));
		
		//February Bounds Check
		assertEquals("Result", false, tester.validateDate("02/40/2011"));
		assertEquals("Result", true, tester.validateDate("02/27/2017"));
		assertEquals("Result", true, tester.validateDate("02/28/2017"));
		assertEquals("Result", true, tester.validateDate("02/29/2017"));
		assertEquals("Result", false, tester.validateDate("02/30/2017"));
		
		//January Bounds Check
		assertEquals("Result", false, tester.validateDate("01/00/2012"));
		assertEquals("Result", true, tester.validateDate("01/31/2012"));
		assertEquals("Result", true, tester.validateDate("01/01/2012"));
		assertEquals("Result", false, tester.validateDate("01/32/2012"));
		assertEquals("Result", false, tester.validateDate("01/01/9001"));
		assertEquals("Result", false, tester.validateDate("January 1, 4, 2008"));
		
		
		//March Bounds Check
		assertEquals("Result", false, tester.validateDate("03/00/2012"));
		assertEquals("Result", true, tester.validateDate("03/31/2012"));
		assertEquals("Result", true, tester.validateDate("03/01/2012"));
		assertEquals("Result", false, tester.validateDate("03/32/2012"));
		assertEquals("Result", false, tester.validateDate("03/01/9001"));
		
		//April Bounds Check
		assertEquals("Result", false, tester.validateDate("04/00/2012"));
		assertEquals("Result", true, tester.validateDate("04/30/2012"));
		assertEquals("Result", true, tester.validateDate("04/01/2012"));
		assertEquals("Result", false, tester.validateDate("04/31/2012"));
		assertEquals("Result", false, tester.validateDate("04/01/9001"));
		
		//May Bounds Check
		assertEquals("Result", false, tester.validateDate("05/00/2012"));
		assertEquals("Result", true, tester.validateDate("05/31/2012"));
		assertEquals("Result", true, tester.validateDate("05/01/2012"));
		assertEquals("Result", false, tester.validateDate("05/32/2012"));
		assertEquals("Result", false, tester.validateDate("05/01/9001"));
		
		//June Bounds Check
		assertEquals("Result", false, tester.validateDate("06/00/2012"));
		assertEquals("Result", true, tester.validateDate("06/30/2012"));
		assertEquals("Result", true, tester.validateDate("06/01/2012"));
		assertEquals("Result", false, tester.validateDate("06/31/2012"));
		assertEquals("Result", false, tester.validateDate("06/01/9001"));
			
		//July Bounds Check
		assertEquals("Result", false, tester.validateDate("07/00/2012"));
		assertEquals("Result", true, tester.validateDate("07/31/2012"));
		assertEquals("Result", true, tester.validateDate("07/01/2012"));
		assertEquals("Result", false, tester.validateDate("07/32/2012"));
		assertEquals("Result", false, tester.validateDate("07/01/9001"));
		
		//August Bounds Check
		assertEquals("Result", false, tester.validateDate("08/00/2012"));
		assertEquals("Result", true, tester.validateDate("08/31/2012"));
		assertEquals("Result", true, tester.validateDate("08/01/2012"));
		assertEquals("Result", false, tester.validateDate("08/32/2012"));
		assertEquals("Result", false, tester.validateDate("08/01/9001"));
		
		//September Bounds Check
		assertEquals("Result", false, tester.validateDate("09/00/2012"));
		assertEquals("Result", true, tester.validateDate("09/30/2012"));
		assertEquals("Result", true, tester.validateDate("09/01/2012"));
		assertEquals("Result", false, tester.validateDate("09/31/2012"));
		assertEquals("Result", false, tester.validateDate("09/01/9001"));
		
		//October Bounds Check
		assertEquals("Result", false, tester.validateDate("10/00/2012"));
		assertEquals("Result", true, tester.validateDate("10/31/2012"));
		assertEquals("Result", true, tester.validateDate("10/01/2012"));
		assertEquals("Result", false, tester.validateDate("10/32/2012"));
		assertEquals("Result", false, tester.validateDate("10/01/9001"));
		
		//November Bounds Check
		assertEquals("Result", false, tester.validateDate("11/00/2012"));
		assertEquals("Result", true, tester.validateDate("11/30/2012"));
		assertEquals("Result", true, tester.validateDate("11/01/2012"));
		assertEquals("Result", false, tester.validateDate("11/31/2012"));
		assertEquals("Result", false, tester.validateDate("11/01/9001"));
		
		//December Bounds Check
		assertEquals("Result", false, tester.validateDate("12/00/2012"));
		assertEquals("Result", true, tester.validateDate("12/31/2012"));
		assertEquals("Result", true, tester.validateDate("12/01/2012"));
		assertEquals("Result", false, tester.validateDate("12/32/2012"));
		assertEquals("Result", false, tester.validateDate("12/01/9001"));
		
		//Garbage Input
		assertEquals("Result", false, tester.validateDate("kjdshfkjshdfkjd"));
		assertEquals("Result", false, tester.validateDate("zilean:zil:jsdfhkjsdf"));
		assertEquals("Result", false, tester.validateDate("112/01/20098"));
		assertEquals("Result", false, tester.validateDate("1/1/1"));
		assertEquals("Result", false, tester.validateDate("12/001/2012"));
		assertEquals("Result", false, tester.validateDate("s12/01/2011"));
		assertEquals("Result", false, tester.validateDate("12/01/0000"));
				
		//Method 2
		String [] cool = new String[1];
		cool[0] = "Zil";
		String [] cool1 = new String[2];
		cool1[0] = "Zil";
		cool1[1] = "Zilean";
		String [] cool2 = new String[3];
		cool2[0] = "Zil";
		cool2[1] = "Zilean";
		cool2[2] = "Bob";
		assertArrayEquals("Result", cool, tester.createNameList("entry:Zil:yay:hsdLaa:ll:", true));
		assertArrayEquals("Result", cool, tester.createNameList("entry:Zil:Zil:Zil:Zil", true));
		assertArrayEquals("Result", cool1, tester.createNameList("entry:Zil:yay:hsdLaa:ll:pop:\nentry:Zilean:yay:5:11", true));
		assertArrayEquals("Result", cool2, tester.createNameList("entry:Zil:yay:hsdLaa:ll:pop:\nentry:Zilean:yay:5:11:pop:\nentry:Bob:sam:singleton:sol", true));
			
		//Method 3
		String [] test2 = new String[5];
		test2[0] = "Do laundry:";
		test2[1] = "Woohoo";
		test2[2] = "Woohoo";
		test2[3] = "lol";
		test2[4] = "Fun times";
		assertEquals("Result", false, tester.validEntry(test2));
		
		test2[0] = "Do laundry";
		test2[1] = "Woohoo";
		test2[2] = "Woohoo";
		test2[3] = "lol";
		test2[4] = "Fun times";
		assertEquals("Result", false, tester.validEntry(test2));
		
		test2[0] = "work";
		assertEquals("Result", true, tester.validEntry(test2));
		
		test2[0] = "personal";
		assertEquals("Result", true, tester.validEntry(test2));
		
		test2[0] = "PERSONAL";
		assertEquals("Result", true, tester.validEntry(test2));
		
		test2[0] = "school";
		assertEquals("Result", true, tester.validEntry(test2));
		
		test2[0] = "wOrk";
		assertEquals("Result", true, tester.validEntry(test2));
		
		test2[0] = "SCHOOL";
		assertEquals("Result", true, tester.validEntry(test2));
		
		test2[0] = "ScHoOl";
		assertEquals("Result", true, tester.validEntry(test2));
		
		//Method 4
		assertEquals("Result", true, tester.passwordMatch("hello", "hello"));
		assertEquals("Result", false, tester.passwordMatch(" hello", "hello"));
		assertEquals("Result", false, tester.passwordMatch("Hello", "hello"));
		assertEquals("Result", false, tester.passwordMatch("hEllo", "hEllo "));
		
		//Method 5
		assertEquals("Result", true, tester.usernamepasswordCombo("hEllo  ", ""));
		assertEquals("Result", false, tester.usernamepasswordCombo("hEllo ", ""));
		assertEquals("Result", true, tester.usernamepasswordCombo("       ", ""));
		assertEquals("Result", false, tester.usernamepasswordCombo("pj", "cj"));
		
		//Method 6
		String[] newentry = new String[1];
		String[] resetfilter = new String[1];
		newentry[0] = "+ New Entry";
		resetfilter[0] = "+ Reset Filter";
		
		assertArrayEquals("Result", resetfilter, tester.filterCheck("entry:Zil:yay:hsdLaa:ll:", true));
		assertArrayEquals("Result", newentry, tester.filterCheck(null, true));
		assertArrayEquals("Result", resetfilter, tester.filterCheck("work", true));
		assertArrayEquals("Result", resetfilter, tester.filterCheck("personal", true));
		assertArrayEquals("Result", resetfilter, tester.filterCheck("school", true));
	}


}
